<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/16
 * Time: 17:01
 */
namespace App\Transformers;

use App\Models\UserGroup;
use League\Fractal\TransformerAbstract;

class UserGroupTransformer extends TransformerAbstract
{


    public function transform(UserGroup $userGroup)
    {
        //  用户群组信息
        return [
            'id' => $userGroup->id,
            'account' => $userGroup->account,
            'group_name' => $userGroup->name,
            'user_name' => $userGroup->user->name,
            'notice' => $userGroup->notice,
            'created_at' => $userGroup->created_at->toDateTimeString(),
            'member_num' => $userGroup->members->count(),
            'member_max' => 200,
        ];
    }

}